package ctd.dome.sync;

/**
 * synchronized 的重入
 * Created by houxr on 2017/4/21 15:54.
 */
public class SyncReenTrant {

    public synchronized void method1() {
        System.out.println("method1...");
        method2();
    }

    public synchronized void method2() {
        System.out.println("method2...");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        method3();
    }

    public synchronized void method3() {
        System.out.println("method3...");
    }

    public static void main(String[] args) {
        final SyncReenTrant syncReenTrant = new SyncReenTrant();
        Thread thread = new Thread(new Runnable() {
            public void run() {
                syncReenTrant.method1();
            }
        });
        thread.start();
    }
}
